/**
 * 不定参数和默认参数
 * author:dengyiping
 * date:2016/08/01
 */

// function myConcat(separator) {
//   var args = Array.prototype.slice.call(arguments, 2);
//   return args.join(separator);
// }

// var arr = myConcat(", ", "red", "orange", "blue");
// console.log(arr.toString());

/*是否包含全部字符串 */
//利用arguments实现 
function containsAll(lage) {
  for (var i = 1; i < arguments.length; i++) {
    var param = arguments[i];
    if (lage.indexOf(param) === -1) {
      return false;
    }
  }
  return true;
}
console.log(containsAll("china","c","hin")); //true
console.log(containsAll("china","u","ma")); //false

//可变参的实现
function containsAllOfes6(lage, ...params) {
  for (var param1 of params) {
    if (lage.indexOf(param1) === -1) {
      return false;
    }
  }
  return true;
}
console.log(containsAllOfes6("china","c","hin")); //true
console.log(containsAllOfes6("china","u","ma")); //false

/**默认参数 */
function weather(temperature=24,other='多云'){
  console.log(`深圳天气：${other},气温${temperature}`);
}

weather();//深圳天气：多云,气温24
weather(25);//深圳天气：多云,气温25
weather(36,"晴");//深圳天气：晴,气温36